<template>
	<view class="content">
		<f-navbar title="我的收藏" fontColor="#333" fontSize="34" bgColor="#fff">
			<view class="u-flex" slot="left">
				<van-icon name="arrow-left" color="#333" size="20" />
			</view>
		</f-navbar>
		<view class="content_box">
			<scroll-view @scrolltolower="lowerBottom" @refresherrefresh="getFresh" scroll-y="true" class="scrollHeight"
				:style="{marginTop:0+'rpx'}" refresher-enabled="true" :scroll-top="scrollTop" :refresher-threshold="100"
				:refresher-triggered="triggered" :scroll-with-animation="true">
				<view v-if="dataList.length>0">


					<view class="content_item" v-for="(item,index) in dataList" :key="index">
						<view class="content_itemtopL">
							<view>
								<image class="content_itemtopLimg" :src="item.logo" mode=""></image>
							</view>
							<view class="content_itemtopLname">{{item.name}}</view>
						</view>
						<view class="content_info" @click="onstoredetail(item)">
							进店
						</view>
					</view>
				</view>
				<!-- 暂无数据 -->
				<view class="zwbox" v-else>
					<view class="zwimgbox">
						<image class="zwimg" src="https://yuanchubao.oss-cn-beijing.aliyuncs.com/zwicon1.png" mode="">
						</image>
					</view>
					<view class="zwtxt">
						暂无数据
					</view>

				</view>
			</scroll-view>

		</view>
	</view>
</template>

<script>
	import fNavbar from '@/uni_modules/f-navbar/components/f-navbar/f-navbar.vue';
	import {
		getCollectList
	} from '../../../utils/app.js'
	export default {
		components: {
			fNavbar
		},
		data() {
			return {
				pages: 1, // 分页数据
				PageSize: 4, // 一页有多少数据
				total: null, // 总条数	
				dataList: [], // 列表数据
				triggered: false, // 设置是否下拉
				scrollTop: 0,
			}
		},
		onLoad() {
			this.getList(true)
		},
		methods: {
			// 进店铺详情
			onstoredetail(e) {
				console.log(e);
				uni.navigateTo({
					url: '/pages/storeDetail/storeDetail?storeid=' + e.store_id
				})
			},

			//触底加载
			lowerBottom() {
				// 判断是否还有下一页数据
				// if (this.pages * this.PageSize >= this.total) return person.showMoreData = true
				// 让页码值自增 +1
				// console.log('999');
				// this.pages += 1
				// 重新获取列表数据
				this.getList(false)
			},
			// 下拉刷新
			getFresh() {
				this.triggered = true,
					this.getList(true)

			},
			// 获取数据
			getList(isPullDownRefresh) {
				let currPage = 1
				if (!isPullDownRefresh) {
					currPage = this.pages + 1
				} else {
					currPage = 1
				}
				getCollectList({
					page: currPage
				}).then(res => {
					console.log(res);
					if (res.code == 1) {
						// uni.hideToast()
						const newdata = res.data.list
						if (isPullDownRefresh) {
							this.dataList = newdata
							this.triggered = false
						} else {
							this.dataList = [...this.dataList, ...newdata]
						}
						this.pages = res.data.page.current
						console.log(this.pages);
						// this.total = res.data.page.total
					} else {
						uni.showToast({
							icon: 'none',
							title: res.info,
							duration: 1000
						})
						if (res.info == '请先登录') {
							setTimeout(function() {
								uni.navigateTo({
									url: '/pages/subPack/Login/Login'
								})
							}, 1000)
						}
					}
				})
			},

		}
	}
</script>

<style>
	page {
		background: #eee;
	}

	.scrollHeight {
		height: 100vh;
	}

	.content_item {
		width: 690rpx;
		height: 162rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		margin: 0 auto;
		margin-top: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.content_itemtopL {
		display: flex;
		align-items: center;
		margin-left: 20rpx;
	}

	.content_itemtopLimg {
		width: 123rpx;
		height: 123rpx;
		border-radius: 10rpx;
		/* 		margin-left: 20rpx;
		margin-right: 10rpx; */
	}

	.content_itemtopLname {
		font-size: 30rpx;
		font-family: Hiragino Sans GB;
		font-weight: 700;
		color: #333333;
		margin-left: 20rpx;
	}

	.content_info {
		width: 132rpx;
		height: 41rpx;
		border: 1rpx solid #EF0E6C;
		border-radius: 20rpx;
		font-size: 24rpx;
		font-family: Hiragino Sans GB;
		font-weight: normal;
		color: #EF0E6C;
		line-height: 41rpx;
		text-align: center;
		margin-right: 20rpx;
	}

	/* 暂无数据 */
	.zwbox {
		/* margin: 0 auto; */
		width: 100%;
		margin: 200rpx auto;
	}

	.zwimgbox {
		width: 141rpx;
		height: 106rpx;
		margin: 0 auto;
	}

	.zwimg {
		width: 100%;
		height: 100%;
	}

	.zwtxt {
		font-size: 24rpx;
		font-family: Hiragino Sans GB;
		font-weight: normal;
		color: #333333;
		margin-top: 30rpx;
		text-align: center;
	}
</style>